package com.stu.controller.student;

import com.stu.Dto.ScholarshipStuInfortmationDto;
import com.stu.result.Result;
import com.stu.pojo.Scholarship;
import com.stu.serive.ScholarshipService;
import com.stu.vo.ScholarshipStuInformationVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/student")
public class ScholarshipController {

    @Autowired
    private ScholarshipService scholarshipService;

    /**
     * 查询所有奖学金基础信息
     * @return
     */
    @GetMapping("/scholarship")
    private Result<List<Scholarship>> selectScholarship(){
        //对于奖学金的查询，应该根据年份的不同去显示，或者每年及时修改相关数据
        log.info("开始查询奖学金基础信息");
        return Result.success(scholarshipService.selectScholarship());
    }

    /**
     * 学生查询已申请项目
     * @return
     */
    @GetMapping("/scholarshipStuInformation")
    private Result<List<ScholarshipStuInformationVo>> selectScholarshipStuInformation(){
        return Result.success(scholarshipService.selectScholarshipStuInformation());
    }

    /**
     * 新增奖学金申请
     * @param scholarshipStuInfortmationDto
     * @return
     */
    @PostMapping("/scholarshipStuInformation")
    private Result insertScholarship(@RequestBody ScholarshipStuInfortmationDto scholarshipStuInfortmationDto){
        //插入学生申请信息
        scholarshipService.insertScholarship(scholarshipStuInfortmationDto);
        return Result.success();
    }
}
